e77c29f4a97dee6fe1ad2c7cce60d83aa2ea6e6d,src/main/java/de/mpc/pia/intermediate/compiler/parser/IdXMLFileParser.java,IdXMLFileParser,getDataFromIdXMLFile,#String#String#PIACompiler#,86
Before Change
}
PeptideSpectrumMatch psm;
psm = compiler.insertNewSpectrum(
charge,
massToCharge,
deltaMass,
retentionTime,
sequence,
missedCleavages,
sourceID,
null,
file,
spectrumID);
specNr++;
// get the peptide from the compiler or, if need be, add it
Peptide peptide;
peptide = compiler.getPeptide(sequence);
if (peptide == null) {
peptide = compiler.insertNewPeptide(sequence);
pepNr++;
}
// add the spectrum to the peptide
peptide.addSpectrum(psm);
// the first score is the "main" score
ScoreModel score;
ScoreModelEnum scoreModel =
ScoreModelEnum.getModelByDescription(
pepID.getScoreType() + "_openmsmainscore");
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
// looks weird, but so the decimals are correct
Double.parseDouble(
String.valueOf(pepHit.getScore())),
scoreModel);
psm.addScore(score);
} else {
// try another alternative
scoreModel = ScoreModelEnum.getModelByDescription(
pepID.getScoreType());
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
// looks weird, but so the decimals are correct
Double.parseDouble(
String.valueOf(pepHit.getScore())),
scoreModel);
psm.addScore(score);
} else {
score = new ScoreModel(
Double.parseDouble(String.valueOf(pepHit.getScore())),
pepID.getScoreType() + "_openmsmainscore",
pepID.getScoreType());
psm.addScore(score);
}
}
// add additional userParams Scores
for (de.mpc.pia.tools.openms.jaxb.UserParamIdXML userParam
: pepHit.getUserParam()) {
// test for any other (known) scores
if (userParam.getType().equals(UserParamType.FLOAT)) {
scoreModel = ScoreModelEnum.getModelByDescription(
idRun.getSearchEngine() + "_" + userParam.getName());
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
Double.parseDouble(userParam.getValue()),
scoreModel);
psm.addScore(score);
} else if (userParam.getName().contains("Posterior Error Probability") ||
userParam.getName().contains("Posterior Probability") ||
userParam.getName().contains("Consensus_")) {
// look for consensus score separately
scoreModel = ScoreModelEnum.getModelByDescription(userParam.getName());
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
Double.parseDouble(userParam.getValue()),
scoreModel);
psm.addScore(score);
}
}
}
// if the target / decoy is set
if (userParam.getName().equals("target_decoy")) {
if (userParam.getValue().equals("target")) {
psm.setIsDecoy(false);
} else if (userParam.getValue().equals("decoy")) {
psm.setIsDecoy(true);
}
}
}
// now add the modifications
for (Map.Entry<Integer, Modification> modIt
: modifications.entrySet()) {
psm.addModification(modIt.getKey(), modIt.getValue());
}
for (Object protRef : pepHit.getProteinRefs()) {
if (!(protRef instanceof ProteinHit)) {
LOGGER.warn("ProteinRef is not a " +
ProteinHit.class.getCanonicalName());
continue;
}
ProteinHit protHit = (ProteinHit)protRef;
FastaHeaderInfos fastaInfo =
FastaHeaderInfos.parseHeaderInfos(
protHit.getAccession());
if (fastaInfo == null) {
LOGGER.error("Could not parse '" +
protHit.getAccession() + "'");
continue;
}
// add the Accession to the compiler (if not already added)
Accession acc = compiler.getAccession(
fastaInfo.getAccession());
if (acc == null) {
acc = compiler.insertNewAccession(
fastaInfo.getAccession(),
protHit.getSequence());
accNr++;
}
acc.addFile(file.getID());
if ((fastaInfo.getDescription() != null) &&
(fastaInfo.getDescription().length() > 0)) {
acc.addDescription(file.getID(),
fastaInfo.getDescription());
}
// add the searchDB to the accession
acc.addSearchDatabaseRef(searchDatabase.getId());
// get the occurrences of the peptide
if ((acc.getDbSequence() != null) && (acc.getDbSequence().trim().length() > 0)) {
List<Integer> startSites = getStartSites(sequence, acc.getDbSequence());
for (Integer start : startSites) {
Integer corrStart = start;
peptide.addAccessionOccurrence(acc,
corrStart,
corrStart + sequence.length() - 1);
}
}
// now insert the peptide and the accession into the accession peptide map
Set<Peptide> accsPeptides =
compiler.getFromAccPepMap(acc.getAccession());
if (accsPeptides == null) {
accsPeptides = new HashSet<Peptide>();
compiler.putIntoAccPepMap(acc.getAccession(), accsPeptides);
}
accsPeptides.add(peptide);
// and also insert them into the peptide accession map
Set<Accession> pepsAccessions =
compiler.getFromPepAccMap(peptide.getSequence());
if (pepsAccessions == null) {
pepsAccessions = new HashSet<Accession>();
compiler.putIntoPepAccMap(peptide.getSequence(),
pepsAccessions);
}
pepsAccessions.add(acc);
}
}
}
After Change
missedCleavages = -1;
}
PeptideSpectrumMatch psm = compiler.createNewPeptideSpectrumMatch(
charge,
massToCharge,
deltaMass,
retentionTime,
sequence,
missedCleavages,
sourceID,
null,
file,
spectrumID);
specNr++;
// get the peptide from the compiler or, if need be, add it
Peptide peptide;
peptide = compiler.getPeptide(sequence);
if (peptide == null) {
peptide = compiler.insertNewPeptide(sequence);
pepNr++;
}
// add the spectrum to the peptide
peptide.addSpectrum(psm);
// the first score is the "main" score
ScoreModel score;
ScoreModelEnum scoreModel =
ScoreModelEnum.getModelByDescription(
pepID.getScoreType() + "_openmsmainscore");
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
// looks weird, but so the decimals are correct
Double.parseDouble(
String.valueOf(pepHit.getScore())),
scoreModel);
psm.addScore(score);
} else {
// try another alternative
scoreModel = ScoreModelEnum.getModelByDescription(
pepID.getScoreType());
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
// looks weird, but so the decimals are correct
Double.parseDouble(
String.valueOf(pepHit.getScore())),
scoreModel);
psm.addScore(score);
} else {
score = new ScoreModel(
Double.parseDouble(String.valueOf(pepHit.getScore())),
pepID.getScoreType() + "_openmsmainscore",
pepID.getScoreType());
psm.addScore(score);
}
}
// add additional userParams Scores
for (de.mpc.pia.tools.openms.jaxb.UserParamIdXML userParam
: pepHit.getUserParam()) {
// test for any other (known) scores
if (userParam.getType().equals(UserParamType.FLOAT)) {
scoreModel = ScoreModelEnum.getModelByDescription(
idRun.getSearchEngine() + "_" + userParam.getName());
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
Double.parseDouble(userParam.getValue()),
scoreModel);
psm.addScore(score);
} else if (userParam.getName().contains("Posterior Error Probability") ||
userParam.getName().contains("Posterior Probability") ||
userParam.getName().contains("Consensus_")) {
// look for consensus score separately
scoreModel = ScoreModelEnum.getModelByDescription(userParam.getName());
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
Double.parseDouble(userParam.getValue()),
scoreModel);
psm.addScore(score);
}
}
}
// if the target / decoy is set
if (userParam.getName().equals("target_decoy")) {
if (userParam.getValue().equals("target")) {
psm.setIsDecoy(false);
} else if (userParam.getValue().equals("decoy")) {
psm.setIsDecoy(true);
}
}
}
// now add the modifications
for (Map.Entry<Integer, Modification> modIt
: modifications.entrySet()) {
psm.addModification(modIt.getKey(), modIt.getValue());
}
compiler.insertCompletePeptideSpectrumMatch(psm);
for (Object protRef : pepHit.getProteinRefs()) {
if (!(protRef instanceof ProteinHit)) {
LOGGER.warn("ProteinRef is not a " +
ProteinHit.class.getCanonicalName());
continue;
}
ProteinHit protHit = (ProteinHit)protRef;
FastaHeaderInfos fastaInfo = FastaHeaderInfos.parseHeaderInfos(protHit.getAccession());
if (fastaInfo == null) {
LOGGER.error("Could not parse '" +
protHit.getAccession() + "'");
continue;
}
// add the Accession to the compiler (if not already added)
Accession acc = compiler.getAccession(fastaInfo.getAccession());
if (acc == null) {
acc = compiler.insertNewAccession(
fastaInfo.getAccession(),
protHit.getSequence());
accNr++;
}
acc.addFile(file.getID());
if ((fastaInfo.getDescription() != null) &&
(fastaInfo.getDescription().length() > 0)) {
acc.addDescription(file.getID(),
fastaInfo.getDescription());
}
// add the searchDB to the accession
acc.addSearchDatabaseRef(searchDatabase.getId());
// get the occurrences of the peptide
if ((acc.getDbSequence() != null) && (acc.getDbSequence().trim().length() > 0)) {
List<Integer> startSites = getStartSites(sequence, acc.getDbSequence());
for (Integer start : startSites) {
Integer corrStart = start;
peptide.addAccessionOccurrence(acc,
corrStart,
corrStart + sequence.length() - 1);
}
}
// now insert the connection between peptide and accession into the compiler
compiler.addAccessionPeptideConnection(acc, peptide);
}
}
}